package com.liuhangs.learning.crowd.webui.controller;

import com.liuhangs.learning.crowd.webui.bean.AdminLoginParam;
import com.liuhangs.learning.crowd.webui.bean.AdminResponse;
import com.liuhangs.learning.crowd.webui.bean.auth.User;
import com.liuhangs.learning.crowd.webui.service.AdminUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 11757
 * @DATE 2020/6/8
 */
@Controller
@RequestMapping("/api/v1/admin/user")
public class AdminUserController {

    private static final Logger logger = LoggerFactory.getLogger(AdminUserController.class);

    @Autowired
    private AdminUserService adminUserService;

    @RequestMapping(value = "query/{id}",produces = "application/json;charset=utf-8")
    public @ResponseBody User queryAdminUserInfo(@PathVariable("id") int id) {
        return null;
    }

    @RequestMapping(value = "/hello",produces = "application/json;charset=utf-8")
    public @ResponseBody String hello() {
        return "123";
    }

    /**
     * 用户登陆
     * @param param
     * @return
     */
/*    @RequestMapping(value = "login", method = {RequestMethod.POST})
    public @ResponseBody ResponseEntity<AdminResponse> login(HttpServletRequest request,AdminLoginParam
            param) {
        logger.info("用户{}开始登陆", param.getUserName());
        String token = request.getHeader("token");
        //TODO 校验token是否过期，没过期就是重复登录，抛出异常
        //AdminResponse response = adminUserService.login(param.getUserName(), param.getUserPwd());
        logger.info("用户{}登陆完成", param.getUserName());
        return ResponseEntity.ok(null);
    }*/

}
